package com.lhm.controller;

import com.lhm.entity.My;
import com.lhm.service.BookService;
import com.lhm.tool.RespJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/api/blog")
public class PublicController {

    @Autowired
    BookService bookService;



    //登录页面
    @RequestMapping("/hi1")
    public String hi1(){
        return "public/1";
    }

    @RequestMapping("go2addBook")
    public String go2addBook()
    {
        return "book/mybook";
    }




    @ResponseBody
    @RequestMapping("addBook") //添加
    public String addBook(@RequestBody My my){

        return bookService.addBook(my);
    }

    @RequestMapping("go2findBook")
    public String go2findBoke(){
        return "book/bookList";
    }

    @ResponseBody
    @RequestMapping("/findByUid")
    public Map findByUid(){
        return RespJson.pack(200,"成功",bookService.findByUid());
    }

}
